home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 001-025 / scopedisk3 / display / tilt.c < prev   
C/C++ Source or Header  |  1995-03-18  |  3KB  |  166 lines

  1. /*
  2.  
  3. [ It's 10:00.  Do you know what the capital of Assyria is? ]
  4.  
  5.     A friend of mine suggested that I write this.  I did, and no
  6. apologies.
  7.  
  8. MANUFACTURE:
  9.     Manx:
  10.     cc tilt.c
  11.     ln tilt.o -lc -o tilt
  12.  
  13.     Lattice:
  14.     (left as an exercise for the reader)
  15.  
  16. USEAGE:
  17.     Run 'tilt'.  When through giggling, click either mouse button to
  18. exit.
  19.  
  20.     Have fun!  I do, but I suppose you already knew that.
  21.  
  22. _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
  23.  ________         ___            Leo L. Schwab
  24.        \        /___--__        The Guy in The Cape
  25.   ___  ___ /\            ---##\        ihnp4!ptsfa!well!ewhac
  26.       /   X  \_____    |  __ _---))            ..or..
  27.      /   /_\--    -----+==____\ // \  _        well ---\
  28. ___ (   o---+------------------O/   \/ \    dual ----> !unicom!ewhac
  29.      \     /            ___ \_  (`o )    hplabs -/       ("AE-wack")
  30.  ____ \___/                 \_/
  31.           Recumbent Bikes:            "Work FOR?  I don't work FOR
  32.         The _O_n_l_y Way To Fly!        anybody!  I'm just having fun."
  33.  
  34. */
  35. /* :ts=8 bk=0
  36.  * tilt.c:    Something to make people giggle.
  37.  *
  38.  * by Leo L. Schwab            8702.23
  39.  *
  40.  * -=RJ Mical=- suggested that I should put my phone number in my PD stuff.
  41.  *    (415) 456-6565
  42.  */
  43.  
  44. #include <exec/types.h>
  45. #include <intuition/intuition.h>
  46.  
  47. #define    DEPTH        2
  48.  
  49.  
  50. extern void    *OpenLibrary(), *OpenWindow(), *OpenScreen();
  51.  
  52.  
  53. struct NewScreen scrdef = {
  54.     0, 0, 0, 0, DEPTH,    /*  Size filled in later  */
  55.     0, 1,
  56.     NULL,            /*  Modes filled in later  */
  57.     CUSTOMSCREEN,
  58.     NULL,
  59.     (UBYTE *) "Dink!",    /*  Title filled in later  */
  60.     NULL, NULL
  61. };
  62.  
  63. struct NewWindow windef = {
  64.     0, 30, 100, 10,
  65.     -1, -1,
  66.     NULL,
  67.     WINDOWDRAG | WINDOWDEPTH | SMART_REFRESH | ACTIVATE,
  68.     NULL, NULL,
  69.     (UBYTE *) "Tilt",
  70.     NULL, NULL,
  71.     0, 0, 0, 0,
  72.     WBENCHSCREEN
  73. };
  74.  
  75. char *msg = "\001\034\022T I L T !\0";
  76.  
  77. struct Screen    *scr;
  78. struct Window    *win;
  79. void        *IntuitionBase, *GfxBase;
  80.  
  81.  
  82. main ()
  83. {
  84.     struct Screen    *wb;
  85.     struct RastPort *rp;
  86.     struct BitMap    *wbm, *mbm;
  87.     long x, y, n;
  88.     register int i;
  89.  
  90.     openstuff ();
  91.  
  92.     wb = win -> WScreen;        /*  Workbench Screen  */
  93.     scrdef.LeftEdge    = wb -> LeftEdge;
  94.     scrdef.TopEdge    = wb -> TopEdge;
  95.     scrdef.Width    = wb -> Width;
  96.     scrdef.Height    = wb -> Height;
  97.     scrdef.ViewModes = wb -> ViewPort.Modes;
  98.     if (!(scr = OpenScreen (&scrdef)))
  99.         die ("Screen open failed.");
  100.     ScreenToBack (scr);
  101.  
  102.     rp = &scr -> RastPort;
  103.     mbm = rp -> BitMap;
  104.     wbm = win -> WScreen -> RastPort.BitMap;
  105.     BltBitMap (wbm, 0L, 0L, mbm, 0L, 0L,
  106.            (long) scrdef.Width, (long) scrdef.Height,
  107.            0xc0L, 0xffL, NULL);
  108.  
  109.     y = scrdef.Height-1;
  110.     for (i=0; i<40; i++) {
  111.         x = i << 4;
  112.         ScrollRaster (rp, 0L, i-20L, x, 0L, x+15L, y);
  113.     }
  114.  
  115.     x = scrdef.Width-1;
  116.     n = scrdef.Height/50;
  117.     for (i=0; i<50; i++) {
  118.         y = i * n;
  119.         ScrollRaster (rp, 25L-i, 0L, 0L, y, x, y+n-1);
  120.     }
  121.     ScreenToFront (scr);
  122.  
  123.     Delay (50L);
  124.     DisplayAlert (RECOVERY_ALERT, msg, 30L);
  125.     closestuff ();
  126. }
  127.  
  128.  
  129. openstuff ()
  130. {
  131.     if (!(IntuitionBase = OpenLibrary ("intuition.library", 0L))) {
  132.         puts ("Intuition missing.");
  133.         exit (100);
  134.     }
  135.  
  136.     if (!(GfxBase = OpenLibrary ("graphics.library", 0L))) {
  137.         puts ("Art shop closed.");
  138.         closestuff ();
  139.         exit (100);
  140.     }
  141.  
  142.     if (!(win = OpenWindow (&windef))) {
  143.         puts ("Window painted shut.");
  144.         closestuff ();
  145.         exit (100);
  146.     }
  147. }
  148.  
  149. die (str)
  150. char *str;
  151. {
  152.     puts (str);
  153.     closestuff ();
  154.     exit (100);
  155. }
  156.  
  157. closestuff ()
  158. {
  159.     if (scr)        CloseScreen (scr);
  160.     if (win)        CloseWindow (win);
  161.     if (GfxBase)        CloseLibrary (GfxBase);
  162.     if (IntuitionBase)    CloseLibrary (IntuitionBase);
  163. }
  164.  
  165.  
  166.